import 'package:ty_smart_watch/utils/Log.dart';

class DateUtil {
  // CommonUtil._internal();
  //
  // factory CommonUtil() => _instance;
  // static final CommonUtil _instance = CommonUtil._internal();

  bool isSameDay(int timeStamp1, int timeStamp2, {bool isMs = false}) {
    DateTime cal1 = DateTime.fromMillisecondsSinceEpoch(isMs
        ? timeStamp1 /*- CommonViewModel().getTimeZoneRawOffset()*/
        : timeStamp1 * 1000 /*- CommonViewModel().getTimeZoneRawOffset()*/);
    DateTime cal2 = DateTime.fromMillisecondsSinceEpoch(isMs
        ? timeStamp2 /*- CommonViewModel().getTimeZoneRawOffset()*/
        : timeStamp2 * 1000 /*- CommonViewModel().getTimeZoneRawOffset()*/);
    return cal1.year == cal2.year && cal1.month == cal2.month && cal1.day == cal2.day;
  }

  bool isToDay(int timeStamp, {bool isMs = false}) {
    int current = DateTime.now().millisecondsSinceEpoch;
    DateTime cal1 = DateTime.fromMillisecondsSinceEpoch(isMs
        ? timeStamp /*- CommonViewModel().getTimeZoneRawOffset()*/
        : timeStamp * 1000 /*- CommonViewModel().getTimeZoneRawOffset()*/);
    DateTime cal2 = DateTime.fromMillisecondsSinceEpoch(current);
    Log.d(
        "isToDay: arg: $timeStamp >> ${cal1.year}  >>  ${cal2.year} >> ${cal1.month}  >>  ${cal2.month} >> ${cal1.day}  >>  ${cal2.day}  ");
    return cal1.year == cal2.year && cal1.month == cal2.month && cal1.day == cal2.day;
  }
}
